package com.apes.fa.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;


@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = FaAssetsIncreaseDecrease.CONST_TABLE_NAME)
public class FaAssetsIncreaseDecrease extends Model {

    public static final String CONST_TABLE_NAME = "fa_assets_increase_decrease";

    @Id
    @Column(name = "id", nullable = false, length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "资产增减", padding = 8)
    @Comment("单号")
    private String id;

    @Column(name = "fa_card_id")
    @Comment("卡片编码")
    private String faCardId;

    @Column(name = "asset_whereabouts")
    @Comment("资产去向")
    private String assetWhereabouts;

    @Column(name = "asset_price")
    @Comment("资产售价")
    private Double assetPrice;

    @Column(name = "transferUnit")
    @Comment("转出单位")
    private String transferUnit;

    @Column(name = "clean_cost")
    @Comment("清理费用")
    private double cleanCost;

    @Column(name = "residual_value_income")
    @Comment("残值收入")
    private double residualValueIncome;

    @Column(name = "decrease_reason")
    @Comment("减少原因")
    private String decreaseReason;

    @Column(name = "responsible_person_opinion")
    @Comment("负责人意见")
    private String responsiblePersonOpinion;

    @Column(name = "use_department_opinion")
    @Comment("使用部门意见")
    private String useDepartmentOpinion;

    @Column(name = "approve_department_opinion")
    @Comment("审批部门意见")
    private String approveDepartmentOpinion;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "resolve_person_id", referencedColumnName = "id")
    @Comment("处理人")
    private PartyRole resolvePerson;

    @Column(name = "resolve_date")
    @Comment("处理日期")
    private Date resolveDate;

    @Column(name = "inventory_number")
    @Comment("盘点编号")
    private String inventoryNumber;
}
